//Component Object
const app = getApp();
const { apiInstance } = app

Component({
  properties: {
    data: {
      type: Object,
      value: {},
      observer: function (e) {
        if (e) {

          this.setData({
            form: e,
          })
        }
      }
    },
    isEdit: {
      type: Boolean,
      value: false,
      observer: function (e) {
        if (e) {
          this.setData({
            isEdit: e,
          })
        }
      }
    },
  },

  data: {
    form: {},
    comfirmPassCurrent:'',
    contentTypeCurrent:[],
    needReCallCurrent:'',
    environmentImpactCurrent:'',
    residentImpactCurrent:'',
    resultCurrent:'',
    refuseTypeCurrent:[],
    contentTypeList:[{
      id:1,
      name:'污水治理措施不当'
    },{
      id:2,
      name:'废气或粉尘治理措施不当'
    },
    {
      id:3,
      name:'噪音污染防治措施不当'
    },
    {
      id:4,
      name:'固废防治措施不到位'
    },
    {
      id:5,
      name:'其他'
    },
    
  ],
  isOrNotList: [{
    id: 1,
    name: '是'
  }, {
    id: 2,
    name: '否'
  }],
  needReCallList:[{
      id:1,
      name:'需要'
    },{
      id:2,
      name:'不需要'
    }],
    resultList:[{
      id:1,
      name:'同意项目实施'
    },{
      id:2,
      name:'不同意项目实施'
    },
    {
      id:3,
      name:'采取安全、环保整改措施后让步接收或同意实施该项目'
    }],
    refuseTypeList:[{
      id:1,
      name:'修改设计或重新规划'
    },{
      id:2,
      name:'补充资料'
    },
    {
      id:3,
      name:'不允许建设'
    },
    {
      id:4,
      name:'其他'
    }],
  },
  
 
  methods: {

    handleResidentImpactChange({detail}){
      this.setData({
        residentImpactCurrent: detail.value,
         'form.residentImpact': detail.value,
       });
    },


    handleEnvironmentImpactChange({detail}){
      this.setData({
        environmentImpactCurrent: detail.value,
         'form.environmentImpact': detail.value,
       });
    },
    handleNeedReCallChange({detail}){
      this.setData({
        needReCallCurrent: detail.value,
         'form.needReCall': detail.value,
       });
    },

    handleResultChange({detail}){
      this.setData({
        resultCurrent: detail.value,
         'form.result': detail.value,
       });
    },

    handleContentTypeChange({detail}){
      this.data.contentTypeCurrent ??= [];
      const index = this.data.contentTypeCurrent?.indexOf(detail.value);
      (index == -1 || index == 'undefined') ? this.data.contentTypeCurrent.push(detail.value) : this.data.contentTypeCurrent.splice(index, 1);
        this.setData({
          contentTypeCurrent: this.data.contentTypeCurrent,
          'form.contentType': this.data.contentTypeCurrent
        });
    },

    handleRefuseTypeChange({detail}){
      this.data.contentTypeCurrent ??= [];
      const index = this.data.contentTypeCurrent?.indexOf(detail.value);
      (index == -1 || index == 'undefined') ? this.data.contentTypeCurrent.push(detail.value) : this.data.contentTypeCurrent.splice(index, 1);
        this.setData({
          refuseTypeCurrent: this.data.contentTypeCurrent,
          'form.refuseType': this.data.contentTypeCurrent
        });

    },

    bindValue(e){

      this.setData({
        [e.target.dataset.itemname]:e.detail.detail.value,
      });


    },
    
   
    
  },
  lifetimes: {
    created: async function () {

    },
    attached: function () {

    },
    ready: async function () {


    },
    moved: function () {

    },
    detached: function () {

    }
  }

});